<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('username');
            $table->string('name');
            $table->string('email')->default("");
            $table->string('phone')->default("");
	        $table->integer('role')->default(1);
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

        Schema::create('students', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users')->ondelete('cascade');
            $table->string('class')->default("");
            $table->string('major')->default("");
            $table->timestamps();
        });

        Schema::create('supervisors', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users')->ondelete('cascade');
            $table->string('major')->default("");
            $table->string('job')->default("");
            $table->string('title')->default("");
            $table->integer('quota')->default(10);
            $table->timestamps();
	});

        Schema::create('admins', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users')->ondelete('cascade');
            $table->boolean('isSuperAdmin')->default(false);
            $table->timestamps();
	});
	
	Schema::create('student_supervisor', function (Blueprint $table) {

	    $table->integer('student_id')->unsigned();
	    $table->foreign('student_id')->references('id')->on('students');

	    $table->integer('supervisor_id')->unsigned();
	    $table->foreign('supervisor_id')->references('id')->on('supervisors');

	    $table->boolean('isApproved')->default(false);
	    $table->timestamps();
	});
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
